//
//  User.m
//  OC-LBWeibo
//
//  Created by 李博 on 15/7/13.
//  Copyright © 2015年 libo. All rights reserved.
//

#import "User.h"

@implementation User

- (void)setProfile_image_url:(NSString *)profile_image_url
{
    _profile_image_url = profile_image_url;
    self.profileUrl = [[NSURL alloc]initWithString:profile_image_url];;
    
}

- (UIImage *)mbrankImage
{
    if (self.mbrank > 0 && self.mbrank < 7) {
        
        NSString *name = [NSString stringWithFormat:@"common_icon_membership_level%d",self.mbrank];
        return [UIImage imageNamed:name];
    }
    return nil;
}

///认证图标
- (UIImage *)verifiedImage
{
    switch (self.verified_type) {
        case 0:
            return [UIImage imageNamed:@"avatar_vip"];
        case 2:
        case 3:
        case 5:
            return [UIImage imageNamed:@"avatar_enterprise_vip"];
        case 220:
            return [UIImage imageNamed:@"avatar_grassroot"];
        default:
            return nil;
    }
}


-(instancetype)initWithDict:(NSDictionary *)dict
{
     NSArray *properties = @[@"id", @"name", @"profile_image_url", @"verified", @"verified_type",@"mbrank"];
    self = [super init];
    if (self) {
        //[self setValuesForKeysWithDictionary:dict];
        for (NSString *key in properties) {
            [self setValue:dict[key] forKey:key];
        }
        
    }
    return self;
}

+(instancetype)userWithDict:(NSDictionary *)dict
{
    return [[self alloc]initWithDict:dict];
}

- (NSString *)description
{
    NSDictionary *dict = [self dictionaryWithValuesForKeys:@[@"id", @"name", @"profile_image_url", @"verified", @"verified_type",@"mbrank"]];
    
    return [NSString stringWithFormat:@"%@", dict];
}


@end
